package com.yhc.my.an_meishia.utils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yhc.my.an_meishia.bean.Beans;
import com.yhc.my.an_meishia.bean.HotShows;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/13.
 */
//解析得到的数据
public class HotJsons {

    private static String json;

    public static List<HotShows> getInfo(String path, Beans beans, int page) {
        List<HotShows> lists = new ArrayList<>();
        //得到json对象
        Gson gson = new Gson();
        //得到路径
        String url = path+"?id="+beans.getId()+"&&type="+beans.getType()+"&&page="+page+"&&count=10";
        //得到json
        try {
            json = OkHttpClientUtils.getStringFromUrl(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Type type = new TypeToken<HotShows>() {
        }.getType();
        lists = gson.fromJson(url, type);
        return lists;
    }
}
